package com.aaa.stock.controller.api;

import com.aaa.entity.StockInventoryLog;
import com.aaa.entity.StockProvider;
import com.aaa.entity.StockPurchase;

import com.aaa.entity.StockPurchaseItem;
import com.aaa.stock.service.PurchaseService;
import com.aaa.stock.vo.PurchaseVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/stock/api/pruchase")
public class ApiPurchaseCpmtrpller {
    @Autowired
    private PurchaseService pruchaseService;
    //分页查询
    @PostMapping("/list/{currentPage}/{pageSize}")
    public Result<IPage<StockPurchase>> list(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody PurchaseVo purchaseVo
    ){
    return pruchaseService.getByPage(currentPage,pageSize,purchaseVo);
    }
    //雪花id
    @GetMapping("xuehua")
    public Result<String>xuehua(){
        System.out.println(pruchaseService);

        return pruchaseService.purchaseIdRequest();
    }
    //分页查询但是筛选出状态为2 ,待审核
    @PostMapping("/list1/{currentPage}/{pageSize}")
    public Result<IPage<StockPurchase>> list1(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody PurchaseVo purchaseVo
    ){
        return pruchaseService.getByPage1(currentPage,pageSize,purchaseVo);
    }

    //审核通过
    @GetMapping("Approved")
    public Result<String>Approved(@RequestParam("status") String status,@RequestParam String purchaseId){
        return pruchaseService.Approved(status,purchaseId);
    }

    //审核不通过
    // 不审核通过
    @GetMapping("NotApproved")
    public Result<String> NotApproved(@RequestParam("status") String status,@RequestParam("purchaseId") String purchaseId,@RequestParam("examine") String  examine){
        System.out.println("examine = " + examine);
        System.out.println("purchaseId = " + purchaseId);
        System.out.println("status = " + status);

        return pruchaseService.NotApproved(status,purchaseId,examine);
    }

}
